{template 'common/header'}
<ul class="nav nav-tabs">
	<li {if $operation == 'display' && $status == '100'}class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => 100))}">全部接龙订单</a>
	</li>
	<li {if $operation == 'display' && $status == '0'}class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => 0))}">待付款</a>
	</li>
	<li {if $operation == 'display' && $status == '1'} class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => 1))}">待发货/自提</a>
	</li>
	<li {if $operation == 'display' && $status == '2'} class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => 2))}">待收货</a>
	</li>
	<li {if $operation == 'display' && $status == '4'}class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => 4))}">已完成</a>
	</li>
	<li {if $operation == 'display' && $status == '-1'}class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => -1))}">已关闭</a>
	</li>
	<li {if $operation == 'display' && $status == '-2'}class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => -2))}">退款订单</a>
	</li>
	<li {if $operation == 'display' && $status == '-3'}class="active"{/if}>
	<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'display', 'status' => -3))}">退款成功订单</a>
	</li>
	{if $operation == 'detail'}
	<li class="active">
		<a href="#">订单详情</a>
	</li>
	{/if}
</ul>

{if $operation == 'display'}

<div class="main">
	<div class="panel panel-info">
		<div class="panel-heading">筛选</div>
		<div class="panel-body">
			<form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
				<input type="hidden" name="c" value="site" />
				<input type="hidden" name="a" value="entry" />
				<input type="hidden" name="m" value="cy163_salesjl" />
				<input type="hidden" name="do" value="jlorder" />
				<div class="form-group">
					<label class="col-xs-12 col-sm-1 control-label">开始时间</label>
					<div class="col-sm-4 col-xs-12">
						{php echo tpl_form_field_date('starttime',$starttime,true);}
					</div>
					<label class="col-xs-12 col-sm-1 control-label">结束时间</label>
					<div class="col-sm-4 col-xs-12">
						{php echo tpl_form_field_date('endtime',$endtime,true);}
					</div>
				</div>
				<div class="form-group">
					<label class="col-xs-12 col-sm-1 control-label">订单号</label>
					<div class="col-sm-4 col-xs-12">
						<input class="form-control" name="keyword" type="text" value="{$_GPC['keyword']}" placeholder="可查询订单号">
					</div>
					<label class="col-xs-12 col-sm-1 control-label">用户信息</label>
					<div class="col-sm-4 col-xs-12">
						<input class="form-control" name="member" type="text" value="{$_GPC['member']}" placeholder="可查询手机号 / 姓名">
					</div>
				</div>
		
				<div class="form-group">
					<label class="col-xs-12 col-sm-1 control-label">发起人</label>
					<div class="col-sm-4 col-xs-12">
						<input class="form-control" name="faqiren" type="text" value="{$_GPC['faqiren']}" placeholder="可查询发起人昵称">
					</div>
					<label class="col-xs-12 col-sm-1 control-label"></label>
					<div class="col-sm-6 col-xs-12">
						<input type="hidden" name="status" value="{$status}" />
						<button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
						<button name="export" onclick="return confirm('确认要导出吗？');return false;" value="export" class="btn btn-default"><i class="fa fa-download"></i> 导出订单</button>
						<button type="button" class="btn btn-default">总记录数：{$total}</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	<div class="panel panel-default">
		<div class="panel-heading">订单 </div>
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
				<tr>
					<th style="width:5%;"></th>
					<th style="width:10%;">订单号</th>
					<th style="width:20%;">收货信息</th>
					<th style="width:8%;">支付方式</th>
					<th style="width:8%;">总价</th>
					<th style="width:6%;">状态</th>
					<th style="width:20%;">下单时间</th>
					<th style="text-align:right;">操作</th>
				</tr>
				</thead>
				<tbody>
				<form action="" method="post">
				{loop $list $item}
				<tr>
					<td><input type="checkbox" class="form-control" name="id[]" value="{$item['id']}" style="width:15px;height:15px;" /></td>
					<td>{$item['ordersn']}</td>
					<td>{$item['address']}</td>
					<td>
						<span class="label label-info">微信支付</span>
					</td>
					<td>{$item['price']} 元</td>
					<td>
						{if $item['status'] == -1}<span class="label label-default">已取消</span>{/if}
						{if $item['status'] == 0}<span class="label label-danger">待付款</span>{/if}
						{if $item['status'] == 1}<span class="label label-info">{if $item['ztdid'] == 0}待发货{else}待自提{/if}</span>{/if}
						{if $item['status'] == 2}<span class="label label-info">待收货</span>{/if}
						{if $item['status'] == 4}<span class="label label-success">已完成</span>{/if}
						{if $item['status'] == -2}<span class="label label-danger">申请退款</span>{/if}
						{if $item['status'] == -3}<span class="label label-success">退款成功</span>{/if}
                    </td>
					<td>{php echo date('Y-m-d H:i:s', $item['createtime'])}</td>
					<td style="text-align:right;">
						<a href="{php echo $this->createWebUrl('jlorder', array('op' => 'detail', 'id' => $item['id']))}" class="btn btn-success btn-sm">查看订单</a>
					</td>
				</tr>
				{/loop}
				<tr>
					<td></td>
					<td colspan="7">
						<input name="token" value="{$_W['token']}" type="hidden">
						<button class="btn btn-default" type="button" id="selectAll">全选</button>
						<button class="btn btn-default" type="button" id="unSelect">全不选</button>
						{if $status == 0}
							<input name="op" value="docancel" type="hidden">
							<input name="submit" onclick="return confirm('此操作不可恢复，确认吗？');return false;" class="btn btn-danger" value="批量取消订单" type="submit">
						{/if}
						{if $status == 2}
							<input name="op" value="jiesuanall" type="hidden">
							<input name="submit" class="btn btn-success" value="强制完成订单" type="submit">
						{/if}
						{if $status == -1}
							<input name="op" value="dodelete" type="hidden">
							<input name="submit" class="btn btn-danger" value="批量删除订单" type="submit">
						{/if}
					</td>
				</tr>
				</form>
				</tbody>
			</table>
		</div>
	</div>
</div>
{$pager}
<script type="text/javascript">
	require(['daterangepicker'], function($){
		$('.daterange').on('apply.daterangepicker', function(ev, picker) {
			$('#form1')[0].submit();
		});
	});
	$("#selectAll").click(function(){  
		$(":checkbox").each(function(){   
			$(this).prop("checked", true);
		});
	});
	$("#unSelect").click(function(){  
		$(":checkbox").each(function(){   
			$(this).prop("checked", false);
		});
	});
</script>

{elseif $operation == 'detail'}
<div class="main">
	<form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
	<div class="panel panel-default">
		<div class="panel-heading">
			订单信息
		</div>
		<div class="panel-body">
			{if $item['transid']}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">微信支付交易号 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['transid']}</p>
				</div>
			</div>
			{/if}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">金额 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['price']} 元</p>
				</div>
			</div>
			{if $item['expresssn']}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">快递单号 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static"><span class="label label-info">{$item['express']}</span><span class="label label-info" style="margin-left:10px;">{$item['expresssn']}</span></p>
				</div>
			</div>
			{/if}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">订单状态 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">
						{if $item['status'] == 0}<span class="label label-info">待付款</span>{/if}
						{if $item['status'] == 1}<span class="label label-info">{if $item['ztdid'] == 0}待发货{else}待自提{/if}</span>{/if}
						{if $item['status'] == 2}<span class="label label-info">待收货</span>{/if}
						{if $item['status'] == 4}<span class="label label-success">已完成</span>{/if}
						{if $item['status'] == -1}<span class="label label-danger">已取消</span>{/if}
						{if $item['status'] == -2}<span class="label label-danger">申请退款</span>{/if}
						{if $item['status'] == -3}<span class="label label-success">退款成功</span>{/if}
					</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">下单日期 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{php echo date('Y-m-d H:i:s', $item['createtime'])}</p>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">备注 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['remark']}</p>
				</div>
			</div>
			
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">退款金额 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['refund_price']} 元</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">退款原因 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['refund_desc']} 元</p>
				</div>
			</div>
		</div>
	</div>
	
	{if $item['user'][0]}
	<div class="panel panel-default">
		<div class="panel-heading">
			用户信息
		</div>
		<div class="panel-body">
			{if $item['ztdid'] == 0}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">姓名 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['user'][0]}</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">手机 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['user'][1]}</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">地址 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['user'][2]}{$item['user'][3]}{$item['user'][4]}{$item['user'][5]}</p>
				</div>
			</div>
			{else}
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">手机 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['user'][0]}</p>
				</div>
			</div>
			<div class="form-group">
				<label class="col-xs-12 col-sm-3 col-md-2 control-label">自提点 :</label>
				<div class="col-sm-9 col-xs-12">
					<p class="form-control-static">{$item['ztdaddress']}</p>
				</div>
			</div>
			{/if}
		</div>
	</div>
	{/if}

	<div class="panel panel-default">
		<div class="panel-heading">商品信息</div>
		<div class="panel-body table-responsive">
			<table class="table table-hover">
				<thead class="navbar-inner">
				<tr>
					<th style="width:5%;">ID</th>
					<th style="width:10%;">商品标题</th>
					<th style="width:15%;">商品规格</th>
					<th style="width:10%;color:red;">成交价</th>
					<th style="width:5%;">数量</th>
				</tr>
				</thead>
				{loop $goodslist $goods}
				<tr>
					<td>{$goods['goodsid']}</td>
					<td>{$goods['goodsname']}</td>
					<td><span class="label label-info">{$goods['optionname']}</span></td>
					<td style='color:red;font-weight:bold;'>{$goods['price']}</td>
					<td>{$goods['total']}</td>
				</tr>
				{/loop}
				<tr>
					<td colspan="6" class="text-right">
						{if $item['status'] == 2}
						<button type="submit" class="btn btn-success" onclick="return confirm('确认完成此订单吗？');" name="finish" value="yes">完成订单</button>
						{/if}
						{if $item['status'] == 0}
						<button type="submit" class="btn btn-warning" onclick="return confirm('订单取消后将会进行相关的退款操作，确认取消此订单吗？');" name="cancelorder" value="yes">取消订单</button>
						{/if}
						<input type="hidden" name="token" value="{$_W['token']}" />
					</td>
				</tr>
			</table>
		</div>
	</div>
	</form>
</div>

<script language='javascript'>
	$(function(){
	});
</script>
{/if}
<script>
	require(['bootstrap'],function($){
		$('.btn').hover(function(){
			$(this).tooltip('show');
		},function(){
			$(this).tooltip('hide');
		});
	});
</script>
{template 'common/footer'}